﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BDShop.Entities;
using BDShop.DAL;
using IsolationLevel = System.Transactions.IsolationLevel;

namespace BDShop.Business
{
   public class BrandService
    {
       /// <summary>
       /// Get Brand By ID
       /// </summary>
       /// <param name="id"></param>
       /// <returns></returns>
       public static Brand GetBrandByID(int id)
       {
           Brand brand = new Brand();
           using (var context = new BDShopEntities(IsolationLevel.ReadUncommitted))
           {
               brand = context.Brands.Where(b => b.ID == id).Single();
           }

           return brand;
       }

       public static List<Brand> GetListBrandCacheModel()
       {
           List<Brand> lstBrand = new List<Brand>();
           using (var context = new BDShopEntities(IsolationLevel.ReadUncommitted))
           {
               lstBrand = context.Brands.Where(s => s.IsCommon == true).Take(5).ToList();
           }

           return lstBrand;
       }
    }
}
